package edu.gdkm.dao;

import edu.gdkm.pojo.StudentInfo;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * 学生信息数据访问接口
 */
public interface StudentInfoDao {
    
    /**
     * 插入学生信息
     */
    @Insert("INSERT INTO student_info(user_id, real_name, gender, birthday, id_card, university, major, education, graduation_time, political_status, hometown, current_city, job_intention, job_type, salary_expectation, self_introduction, create_time, update_time) VALUES(#{userId}, #{realName}, #{gender}, #{birthday}, #{idCard}, #{university}, #{major}, #{education}, #{graduationTime}, #{politicalStatus}, #{hometown}, #{currentCity}, #{jobIntention}, #{jobType}, #{salaryExpectation}, #{selfIntroduction}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(StudentInfo studentInfo);
    
    /**
     * 根据ID删除学生信息
     */
    @Delete("DELETE FROM student_info WHERE id = #{id}")
    int deleteById(Long id);
    
    /**
     * 更新学生信息
     */
    @Update("UPDATE student_info SET user_id = #{userId}, real_name = #{realName}, gender = #{gender}, birthday = #{birthday}, id_card = #{idCard}, university = #{university}, major = #{major}, education = #{education}, graduation_time = #{graduationTime}, political_status = #{politicalStatus}, hometown = #{hometown}, current_city = #{currentCity}, job_intention = #{jobIntention}, job_type = #{jobType}, salary_expectation = #{salaryExpectation}, self_introduction = #{selfIntroduction}, update_time = #{updateTime} WHERE id = #{id}")
    int update(StudentInfo studentInfo);
    
    /**
     * 根据ID查询学生信息
     */
    @Select("SELECT id, user_id, real_name, gender, birthday, id_card, university, major, education, graduation_time, political_status, hometown, current_city, job_intention, job_type, salary_expectation, self_introduction, create_time, update_time FROM student_info WHERE id = #{id}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "realName", column = "real_name"),
        @Result(property = "birthday", column = "birthday"),
        @Result(property = "idCard", column = "id_card"),
        @Result(property = "university", column = "university"),
        @Result(property = "major", column = "major"),
        @Result(property = "education", column = "education"),
        @Result(property = "graduationTime", column = "graduation_time"),
        @Result(property = "politicalStatus", column = "political_status"),
        @Result(property = "hometown", column = "hometown"),
        @Result(property = "currentCity", column = "current_city"),
        @Result(property = "jobIntention", column = "job_intention"),
        @Result(property = "jobType", column = "job_type"),
        @Result(property = "salaryExpectation", column = "salary_expectation"),
        @Result(property = "selfIntroduction", column = "self_introduction"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    StudentInfo selectById(Long id);
    
    /**
     * 查询所有学生信息
     */
    @Select("SELECT id, user_id, real_name, gender, birthday, id_card, university, major, education, graduation_time, political_status, hometown, current_city, job_intention, job_type, salary_expectation, self_introduction, create_time, update_time FROM student_info")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "realName", column = "real_name"),
        @Result(property = "birthday", column = "birthday"),
        @Result(property = "idCard", column = "id_card"),
        @Result(property = "university", column = "university"),
        @Result(property = "major", column = "major"),
        @Result(property = "education", column = "education"),
        @Result(property = "graduationTime", column = "graduation_time"),
        @Result(property = "politicalStatus", column = "political_status"),
        @Result(property = "hometown", column = "hometown"),
        @Result(property = "currentCity", column = "current_city"),
        @Result(property = "jobIntention", column = "job_intention"),
        @Result(property = "jobType", column = "job_type"),
        @Result(property = "salaryExpectation", column = "salary_expectation"),
        @Result(property = "selfIntroduction", column = "self_introduction"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    List<StudentInfo> selectAll();
    
    /**
     * 根据用户ID查询学生信息
     */
    @Select("SELECT id, user_id, real_name, gender, birthday, id_card, university, major, education, graduation_time, political_status, hometown, current_city, job_intention, job_type, salary_expectation, self_introduction, create_time, update_time FROM student_info WHERE user_id = #{userId}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "realName", column = "real_name"),
        @Result(property = "birthday", column = "birthday"),
        @Result(property = "idCard", column = "id_card"),
        @Result(property = "university", column = "university"),
        @Result(property = "major", column = "major"),
        @Result(property = "education", column = "education"),
        @Result(property = "graduationTime", column = "graduation_time"),
        @Result(property = "politicalStatus", column = "political_status"),
        @Result(property = "hometown", column = "hometown"),
        @Result(property = "currentCity", column = "current_city"),
        @Result(property = "jobIntention", column = "job_intention"),
        @Result(property = "jobType", column = "job_type"),
        @Result(property = "salaryExpectation", column = "salary_expectation"),
        @Result(property = "selfIntroduction", column = "self_introduction"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    StudentInfo selectByUserId(Long userId);
}
